package mycsveditor.editors;

import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.Token;

public class CSVPartitionScanner extends RuleBasedPartitionScanner {
	public final static String CSV_COMMENT = "__csv_comment";
	public final static String JAVA_CALL = "__java_call";
	
	public CSVPartitionScanner() {

		IToken csvComment = new Token(CSV_COMMENT);
		IToken call = new Token(JAVA_CALL);

		IPredicateRule[] rules = new IPredicateRule[2];

		EndOfLineRule csvCommentRule = new EndOfLineRule("#", csvComment);
		csvCommentRule.setColumnConstraint(0);
		rules[0] = csvCommentRule;
		rules[1] = new CSVJavaCallRule(call);

		setPredicateRules(rules);
	}
}
